/* $Id: TournamentFrame.java 39 2009-07-24 22:48:06Z h_m_r@gmx.de $ */
package org.jugger.tournament.gui.view;

import java.io.File;

import javax.swing.JInternalFrame;

import org.jugger.tournament.model.Tournament;

import util.I18N;

public class TournamentFrame extends JInternalFrame {

	private static final long serialVersionUID = -5838866557408274774L;

	static int openFrameCount = 0;
	static final int xOffset = 20, yOffset = 20;

	private Tournament tournament = null;
	private File file;
	private int openFrameNumber;

	public TournamentFrame(Tournament tournament, File file) {
//	    super(I18N.__("tournamentFrameTitle", new Object[]{++openFrameCount}),
//	          true, //resizable
//	          true, //closable
//	          true, //maximizable
//	          true);//iconifiable
	    super("",
		          true, //resizable
		          true, //closable
		          true, //maximizable
		          true);//iconifiable

	    this.tournament = tournament;
	    openFrameNumber = ++openFrameCount;
	    setFile(file);
		getContentPane().add(new TournamentView(tournament));

		pack();
		setSize(880, 630);
	    setLocation(xOffset*openFrameNumber, yOffset*openFrameNumber);
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
		if(file==null) {
			setTitle(I18N.__("tournamentFrameTitleUnnamed", new Object[]{openFrameNumber}));
		}
		else {
			setTitle(I18N.__("tournamentFrameTitle", new Object[]{file.toString()}));
		}
	}

	public Tournament getTournament() {
		return tournament;
	}
}
